package org.pragma;

import org.pragma.objects.PragmaList;
import org.pragma.objects.PragmaObject;

public class PragmaBlockOld extends PragmaObject{

	PragmaList<PragmaCall> calls = new PragmaList<PragmaCall>();
	
	public PragmaBlockOld add(PragmaCall statement) {
		calls.add(statement);
		return this;
	}
	
	public PragmaObject execute(PragmaContext ctx) throws Exception{
		PragmaObject result = null;
		for (PragmaCall call : calls){
			//System.out.println("executing : "+call.toString());
			result = call.execute(ctx);
			
		}
		return result;
	}

	public PragmaList<PragmaCall> getCalls() {
		return calls;
	}
	
	public String display(String margin){
		String  result = margin+"Block\n";
		for (PragmaCall call : calls){
			//System.out.println("executing : "+call.toString());
			result += call.display(margin+displayIndent)+"\n";
			
		}
		 return result;
	}
	
}
